home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / BEERSRC.ZIP / BIT0.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-26  |  1.7 KB  |  90 lines

  1.  
  2.  
  3. #ifndef __COMPACT__
  4.    #error Memory Model must be compact
  5. #endif
  6.  
  7. #include <string.h>
  8. #include <stdlib.h>
  9. #include <conio.h>
  10. #include <stdio.h>
  11. #include <alloc.h>
  12. #include <io.h>
  13. #include <fcntl.h>
  14. #include <sys\stat.h>
  15. #include <dos.h>
  16.  
  17.  
  18. #include "sound.h"
  19.  
  20. struct sndstrc lall;
  21.  
  22.  
  23. int do_the_nasty_job(char *infile, char *outfile)
  24. {
  25.    int   in, out;
  26.    long  size, objsize;
  27.    char  *ptr;
  28.    int   y;
  29.    char  file[80];
  30.    int   voc;
  31.    int   ref, tmp1, tmp2;
  32.    unsigned i;
  33.  
  34.  
  35.    strcpy(file, infile); strcat(file, ".snd");
  36.    in = open(file, O_RDONLY | O_BINARY, S_IREAD);
  37.    out = open(outfile, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, S_IWRITE);
  38.    if (out == -1) {
  39.       perror("writefile : ");
  40.       return -1;
  41.    }
  42.  
  43.    ptr = malloc(60000);
  44.  
  45.    read(in, ptr, sizeof(struct sndstrc));
  46.    write(out, ptr, sizeof(struct sndstrc));
  47.    size = filelength(in) - sizeof(struct sndstrc);
  48.  
  49.    while(size > 60000) {
  50.       read(in, ptr, 60000);
  51.       for (i = 0; i < 60000; i++)
  52.      ptr[i] = ptr[i] & 0xfe;
  53.       write(out, ptr, 60000);
  54.       size -= 60000;
  55.    }
  56.    read(in, ptr, size);
  57.    for (i = 0; i < size; i++)
  58.       ptr[i] = ptr[i] & 0xfe;
  59.    write(out, ptr, size);
  60.  
  61.    free(ptr);
  62.  
  63.    close(out); close(in);
  64.  
  65.    return 0;
  66. }
  67.  
  68.  
  69.  
  70. void main(void)
  71. {
  72.    char   infile[80], outfile[80];
  73.    char   text[80];
  74.    int    filvar;
  75.  
  76.  
  77.    printf("\n\nBit 0 clearer [c] 1993 Alpha-Helix.\n\n");
  78.    printf("Input File [.SND]: ");
  79.    fflush(stdin);
  80.    scanf("%s", infile);
  81.    printf("Sound File [.SND]: ");
  82.    fflush(stdin);
  83.    scanf("%s", outfile);
  84.    strcat(outfile, ".SND");
  85.    do_the_nasty_job(infile, outfile);
  86.  
  87. }
  88.  
  89.  
  90.